<?php
class MenuAction {
	public function index() {
		global $sMethod;
		$sMethod = 'index';
		$sUrl = './?' . Base::getSearch ( array ('m', 'id' ) );
		if ($_POST) {
			$aInfo = $_POST;
			if ($_GET ['id']) {
				$aInfo ['id'] = $_GET ['id'];
				Base::$oBase->Menu_edit_model ( $aInfo );
			} else {
				Base::$oBase->Menu_add_model ( $aInfo );
			}
			Base::location ( $sUrl );
		}
		Base::$oBase->Menu_getList_model ();
		Base::$oBase->Template_assign ( 'url', $sUrl );
		Base::$oBase->Template_assign ( 'top', Base::$oBase->Menu_getTopArray_model () );
		Base::$oBase->Template_assign ( 'list', Base::$oBase->Menu_getList_model () );
		if ($_GET ['id']) {
			Base::$oBase->Template_assign ( 'info', Base::$oBase->Menu_get_model ( $_GET ['id'] ) );
		}
	}
	
	public function del() {
		if ($_POST ['confirm']) {
			Base::$oBase->Menu_del_model ( $_GET ['id'] );
		}
		$this->index ();
	}
}